package com.glsc.ngateway.common.api.filetransfer.feign;

import com.glsc.ngateway.common.api.common.config.FeignMultipartSupportConfig;
import com.glsc.ngateway.common.api.filetransfer.dto.SmbFileDto;
import com.glsc.ngateway.common.api.filetransfer.resp.FileTransferResponse;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

@FeignClient(value = "eureka-client-filetransfer", configuration = FeignMultipartSupportConfig.class)
interface IFeignFiletransferService {

    @ApiImplicitParams({@ApiImplicitParam(name = "ip", value = "服务器ip", required = true, paramType = "path", dataTypeClass = String.class), @ApiImplicitParam(name = "userAccount", value = "服务器账户", required = true, paramType = "path", dataTypeClass = String.class), @ApiImplicitParam(name = "passwd", value = "服务器密码", required = true, paramType = "path", dataTypeClass = String.class), @ApiImplicitParam(name = "shareFolderName", value = "文件目录", required = true, paramType = "path", dataTypeClass = String.class)})
    @GetMapping("/gatewayFileTransfer/listFiles")
    FileTransferResponse<List<SmbFileDto>> listFiles(String ip, String userAccount, String passwd, String shareFolderName);

    @ApiImplicitParams({@ApiImplicitParam(name = "ip", value = "服务器ip", required = true, paramType = "path", dataTypeClass = String.class), @ApiImplicitParam(name = "userAccount", value = "服务器账户", required = true, paramType = "path", dataTypeClass = String.class), @ApiImplicitParam(name = "passwd", value = "服务器密码", required = true, paramType = "path", dataTypeClass = String.class), @ApiImplicitParam(name = "shareFolderName", value = "文件目录", required = true, paramType = "path", dataTypeClass = String.class), @ApiImplicitParam(name = "remoteFileName", value = "文件名", required = true, paramType = "path", dataTypeClass = String.class)})
    @GetMapping("/gatewayFileTransfer/checkFileExist")
    FileTransferResponse<Boolean> checkFileExist(String ip, String userAccount, String passwd, String shareFolderName, String remoteFileName);

    @ApiImplicitParams({@ApiImplicitParam(name = "ip", value = "服务器ip", required = true, paramType = "path", dataTypeClass = String.class), @ApiImplicitParam(name = "userAccount", value = "服务器账户", required = true, paramType = "path", dataTypeClass = String.class), @ApiImplicitParam(name = "passwd", value = "服务器密码", required = true, paramType = "path", dataTypeClass = String.class), @ApiImplicitParam(name = "shareFolderName", value = "文件目录", required = true, paramType = "path", dataTypeClass = String.class), @ApiImplicitParam(name = "file", value = "文件", required = true, paramType = "form", dataTypeClass = MultipartFile.class), @ApiImplicitParam(name = "cover", value = "是否覆盖（Y/N）", required = true, paramType = "path", dataTypeClass = String.class)})
    @PostMapping("/gatewayFileTransfer/putFile")
    FileTransferResponse<String> putFile(String ip, String userAccount, String passwd, String shareFolderName, String cover, @RequestPart("file") MultipartFile file);

    @ApiImplicitParams({@ApiImplicitParam(name = "ip", value = "服务器ip", required = true, paramType = "path", dataTypeClass = String.class), @ApiImplicitParam(name = "userAccount", value = "服务器账户", required = true, paramType = "path", dataTypeClass = String.class), @ApiImplicitParam(name = "passwd", value = "服务器密码", required = true, paramType = "path", dataTypeClass = String.class), @ApiImplicitParam(name = "shareFolderName", value = "文件目录", required = true, paramType = "path", dataTypeClass = String.class), @ApiImplicitParam(name = "remoteFileName", value = "文件名", required = true, paramType = "path", dataTypeClass = String.class)})
    @GetMapping("/gatewayFileTransfer/getFile")
    FileTransferResponse<String> getFile(String ip, String userAccount, String passwd, String shareFolderName, String remoteFileName, HttpServletResponse response);

    @ApiImplicitParams({@ApiImplicitParam(name = "ip", value = "服务器ip", required = true, paramType = "path", dataTypeClass = String.class), @ApiImplicitParam(name = "userAccount", value = "服务器账户", required = true, paramType = "path", dataTypeClass = String.class), @ApiImplicitParam(name = "passwd", value = "服务器密码", required = true, paramType = "path", dataTypeClass = String.class), @ApiImplicitParam(name = "shareFolderName", value = "文件目录", required = true, paramType = "path", dataTypeClass = String.class), @ApiImplicitParam(name = "remoteFileName", value = "文件名", required = true, paramType = "path", dataTypeClass = String.class)})
    @GetMapping("/gatewayFileTransfer/deleteFile")
    FileTransferResponse<String> deleteFile(String ip, String userAccount, String passwd, String shareFolderName, String remoteFileName);
}